package com.xbw.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sjh.vo.Bis_bag_record;
import com.sjh.vo.Bis_beauty_record;
import com.sjh.vo.Bis_cash_record;
import com.xbw.bean.Bis_Shop;
import com.xbw.service.Bis_cash_recordService;
import com.xbw.service.ShopService;

@Controller
@RequestMapping("cashrecord")
public class Bis_cash_recordController {
   
	@Autowired
	private Bis_cash_recordService bcr;
	@Autowired
	private ShopService shop;
	//璺冲埌鐜伴噾娴佹按椤甸潰
	@RequestMapping("listAll")
	public ModelAndView listAll(HttpServletRequest request,@RequestParam(value="page",defaultValue="1")int page){
		ModelAndView md=new ModelAndView();
		Map<String, Object> map=remap(request);
		 PageHelper.startPage(page, 5);
		 List<Bis_cash_record> list=bcr.listrecord(map);
		 PageInfo<Bis_cash_record> info=new PageInfo<>(list);
		 md.addObject("info", info);
		 md.addObject("map", map);
		 md.setViewName("record/money");
		return  md;
	}
	//灏佽妯＄硦鏌ヨ鐨勬柟娉�
	private Map<String, Object>  remap(HttpServletRequest request){
		Map<String, Object> map=new HashMap<String,Object>();
		map.put("order_id", request.getParameter("order_id"));
		map.put("mobile", request.getParameter("mobile"));
		map.put("pay_way", request.getParameter("pay_way"));
		map.put("record_type", request.getParameter("record_type"));
		map.put("ptime", request.getParameter("ptime"));
		map.put("ntime", request.getParameter("ntime"));
		map.put("bag_name",request.getParameter("bag_name") );
		map.put("mob",request.getParameter("mob") );
		map.put("shop_id", request.getParameter("shop_id"));
		return map;
	}
	//璺冲埌棰滃�兼祦姘磋〃
	@RequestMapping("listbeautyrecord")
	public ModelAndView listbeautyrecord(HttpServletRequest request,@RequestParam(value="page",defaultValue="1")int page){
		ModelAndView md=new ModelAndView();
		Map<String, Object> map=remap(request);
		 PageHelper.startPage(page, 5);
		 List<Bis_beauty_record> list=bcr.listbeautyrecord(map);
		 PageInfo<Bis_beauty_record> info=new PageInfo<>(list);
		 md.addObject("info", info);
		 md.addObject("map", map);
		 md.setViewName("record/beautyrecord");
		return  md;
	}
	//璺冲埌绀煎寘鍒嗕韩璁板綍椤甸潰
	@RequestMapping("listbagrecord")
	public ModelAndView listbagrecord(HttpServletRequest request,@RequestParam(value="page",defaultValue="1")int page){
		ModelAndView md=new ModelAndView();
		Map<String, Object> map=remap(request);
		 PageHelper.startPage(page, 5);
		 List<Bis_bag_record> list=bcr.listbagrecord(map);
		 PageInfo<Bis_bag_record> info=new PageInfo<>(list);
		 md.addObject("info", info);
		 md.addObject("map", map);
		 md.setViewName("record/bagrecord");
		return  md;
	}
	//璺冲埌骞冲彴璐㈠姟椤甸潰
	@RequestMapping("listshop")
	public ModelAndView listshop(HttpServletRequest request,@RequestParam(value="page",defaultValue="1")int page){
		ModelAndView md=new ModelAndView();
		Map<String, Object> map=remap(request);
		 PageHelper.startPage(page, 5);
		 List<Bis_Shop> list=bcr.listshop(map);
		 PageInfo<Bis_Shop> info=new PageInfo<>(list);
		 List<Bis_Shop> list2=shop.listAll(new HashMap<>());
		 md.addObject("list", list2);
		 md.addObject("info", info);
		 md.addObject("map", map);
		 md.setViewName("record/listshop");
		return  md;
	}
}
